﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DCRF.Common.Interface;
using AdminConsole.TreeNodes.Nodes.Single;
using DCRF.Common.Core;
using DCRF.Common.Support;

namespace AdminConsole.TreeNodes.Nodes.Collection
{
    class GlobalConnectorsNode: BaseNode
    {
        public IBlockWeb myWeb = null;

        public GlobalConnectorsNode(IBlockWeb web)
        {
            myWeb = web;            
        }

        public override void Attach(TreeNode myNode)
        {
            myNode.Tag = this;
            myNode.SelectedImageKey = myNode.ImageKey = "GlobalConnectors";
            myNode.Text = "Global Connectors";
            addTempNode(myNode);
        }


        protected override void buildChildrenList()
        {
            children.Clear();

            List<string> conKeys = myWeb.GetBlockWebMetaInfo(BlockWebMetaInfoType.GlobalConnectorKeys, null) as List<string>;

            foreach (string key in conKeys)
            {
                children.Add(new ConnectorNode(myWeb, Guid.Empty, key));
            }
        }

        public override List<string> GetCommands(TreeNode myNode)
        {
            return new List<string>() { "REF" };
        }

        public override void ExecuteCommand(string cmdKey, TreeNode myNode)
        {
            if (cmdKey == "REF") refresh(myNode);
        }
    }
}
